using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class ShareableSkinItem : SkinItem
{
	public SkinPlatform platform;

	public Button openButton;

	private bool pageOpening;

	private bool leftApp;

	private void Start()
	{
		platform = GameManager.Instance.FidgetStore.fidgetTypes[skinIndex].skinPlatform;
		if (!base.Opened)
		{
			openButton.onClick.AddListener(delegate
			{
				AdManager.Instance.ShowVideo(()=>{
					StartCoroutine(OpenRoutine());
				});
				
			});
			openButton.gameObject.SetActive(true);
			selectedPanel.SetActive(false);
			selectButton.gameObject.SetActive(false);
		}
		else if (base.selected)
		{
			SelectItem();
		}
		else
		{
			DeselectItem();
		}
	}

	public override void SelectItem()
	{
		base.SelectItem();
		openButton.gameObject.SetActive(false);
	}

	private void OnApplicationPause(bool paused)
	{
		if (paused)
		{
			leftApp = true;
		}
	}

	private IEnumerator OpenRoutine()
	{
		yield return new WaitForSeconds(0.5f);
		OpenItem();
		pageOpening = false;
		UIScreenController.instance.OpenCongrats();
	}
}
